import { request } from '@umijs/max'

// 获得商品数据
export function GetGoodsFnc (data: {query: string, pagenum: number, pagesize: number}) {
  return request(`/goods?query=${data.query}&pagenum=${data.pagenum}&pagesize=${data.pagesize}`, {
    method: 'get'
  })
}

// 显示编辑商品盒子
export function ShowEditProductFnc (id: number) { 
    return request(`/goods/${id}`,{
      method: 'get'
    })
  }
  
  // 编辑商品  
  export function EditProductFnc (id: number, data: {goods_name: string, goods_price: number, goods_number: number, goods_weight: number}) { 
     return request(`/goods/${id}`, {
      method: 'put',
      data: data
    })
  }
  
  // 删除商品
  export function DeleteProductsFnc (id: number) {
    return request(`/goods/${id}`, {
      method: 'delete'
    })
  }
  
  // 添加商品按钮里面 获得商品分类
  export function GetProductCategoryFnc () {
    return request('/categories', {
      method: 'get'
    })
  }